const {STATUS: {SUCCESS}} = require('./RES_CODE')

class Response {
  //构造函数
  constructor(
    {status = SUCCESS, data = null, message = ''} = 
    {status: SUCCESS, data: null, message: ''}) {
    this.status = status
    if(status != SUCCESS) {
      this.message = message
    }
    this.data =data
  }
}

class ResponseError extends Error{
  constructor(message) {
    super(message)
  }
  toJSON() {
    return "ResponseError: " + this.message
  }
}

module.exports = {
  Response,
  ResponseError
}